package fm.last.api
{
    import flash.net.URLRequestMethod;
    import flash.net.URLVariables;
    
    import fm.last.Agent;
    import fm.last.RestAPI;
    
    final public class GroupAPI extends RestAPI
    {
        // those in comment are not implemented yet
        public static const GROUP_GET_MEMBERS:String              = "group.getMembers";
        public static const GROUP_GET_WEEKLY_ALBUM_CHART:String   = "group.getWeeklyAlbumChart";
        public static const GROUP_GET_WEEKLY_ARTIST_CHART:String  = "group.getWeeklyArtistChart";
        public static const GROUP_GET_WEEKLY_CHART_LIST:String    = "group.getWeeklyChartList";
        public static const GROUP_GET_WEEKLY_TRACK_CHART:String   = "group.getWeeklyTrackChart";
        
        public function GroupAPI(agent:Agent)
        {
            super(agent);
        }

        /* ********************************************************************/
        
        /** group.getMembers */
        public function getMembers(onComplete:Function, 
                                   onError:Function,
                                   group:String):void
        {
            var urlVars:URLVariables = new URLVariables();
            urlVars["method"] = GroupAPI.GROUP_GET_MEMBERS;
            urlVars["group"] = group;
            requestAPI(URLRequestMethod.GET, urlVars, false, onComplete, onError);        
        }
        
        
        /** group.getWeeklyAlbumChart */
        public function getWeeklyAlbumChart(onComplete:Function, 
                                            onError:Function,
                                            group:String,
                                            from:String=null,
                                            to_:String=null):void
        {
            var urlVars:URLVariables = new URLVariables();
            urlVars["method"] = GroupAPI.GROUP_GET_WEEKLY_ALBUM_CHART;
            urlVars["group"] = group;
            if (from!=null) urlVars["from"] = from;
            if (to_!=null)  urlVars["to"]   = to_;
            requestAPI(URLRequestMethod.GET, urlVars, false, onComplete, onError);        
        }
        
        

        /** group.getWeeklyArtistChart */
        public function getWeeklyArtistChart(onComplete:Function, 
                                            onError:Function,
                                            group:String,
                                            from:String=null,
                                            to_:String=null):void
        {
            var urlVars:URLVariables = new URLVariables();
            urlVars["method"] = GroupAPI.GROUP_GET_WEEKLY_ARTIST_CHART;
            urlVars["group"] = group;
            if (from!=null) urlVars["from"] = from;
            if (to_!=null)  urlVars["to"]   = to_;
            requestAPI(URLRequestMethod.GET, urlVars, false, onComplete, onError);        
        }
        

        /** group.getWeeklyChartList */
        public function getWeeklyChartList(onComplete:Function, 
                                            onError:Function,
                                            group:String):void
        {
            var urlVars:URLVariables = new URLVariables();
            urlVars["method"] = GroupAPI.GROUP_GET_WEEKLY_CHART_LIST;
            urlVars["group"] = group;
        }
        
           
        /** group.getWeeklyTrackChart */
        public function getWeeklyTrackChart(onComplete:Function, 
                                            onError:Function,
                                            group:String,
                                            from:String=null,
                                            to_:String=null):void
        {
            var urlVars:URLVariables = new URLVariables();
            urlVars["method"] = GroupAPI.GROUP_GET_WEEKLY_TRACK_CHART;
            urlVars["group"] = group;
            if (from!=null) urlVars["from"] = from;
            if (to_!=null)  urlVars["to"]   = to_;
            requestAPI(URLRequestMethod.GET, urlVars, false, onComplete, onError);        
        }
                
    }
}